package com.example.mymvvmdemo.api;


import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.QueryMap;
import retrofit2.http.Url;

/**
 * 后续会将请求进行优化，统一封装，根据请求方式进行统一
 */
public interface API {

    //TODO 普通GET请求
    @GET
    Observable<ResponseBody> loadGet(@Url String url, @Header("Authorization") String auth_token, @QueryMap() HashMap<String, String> map);

    //TODO 普通DELETE请求
    @DELETE
    Observable<ResponseBody> loadDelete(@Url String url, @Header("Authorization") String auth_token, @QueryMap() HashMap<String, String> map);

    //TODO 只有一个body参数的post请求
    @POST
    @Headers({
            "Content-Type: application/json",
            "Accept: application/json",
            "Cache-Control: no-cache",
            "Pragma: no-cache"
    })
    Observable<ResponseBody> loadPostBody(@Url String url, @Header("Authorization") String auth_token, @Body RequestBody body);

    //TODO 普通的post请求
    @POST
    Observable<ResponseBody> loadPost(@Url String url, @Header("Authorization") String auth_token, @QueryMap() HashMap<String, String> map);

    //TODO 同时具备Query和Body的post请求
    @POST
    Observable<ResponseBody> loadPostQueryBody(@Url String url, @Header("Authorization") String auth_token, @QueryMap() HashMap<String, String> map, @Body RequestBody body);

    @Multipart
    @POST
    Observable<ResponseBody> uploadImage(
            @Url String url,
            @Header("Authorization") String auth_token,
            @Part MultipartBody.Part image,
            @QueryMap() HashMap<String, String> map
    );

    //TODO 普通put请求
    @PUT
    Observable<ResponseBody> loadPut(@Url String url, @Header("Authorization") String auth_token, @QueryMap() HashMap<String, String> map);

    //TODO 带Body的Put请求
    @PUT
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    Observable<ResponseBody> loadPutBody(@Url String url, @Header("Authorization") String auth_token, @Body RequestBody body, @QueryMap() HashMap<String, String> map);


}
